import Vue from 'vue';
import VueRouter from 'vue-router';

import Home from '@/views/Home.vue';
import Add from '@/views/add/add.vue';
import Mine from '@/views/mine/mine.vue';
import RecentList from '@/views/recentList/recentList.vue';

import Check from '@/views/check/Check.vue';
import Attendance from '@/views/check/Attendance.vue';
import Extrawork from '@/views/check/Extrawork.vue';
import Evection from '@/views/evection/Evection.vue';
import BusinessTrip from '@/views/evection/BusinessTrip.vue';
import BusinessTripBurse from '@/views/evection/BusinessTripBurse.vue';
import Company from '@/views/company/Company.vue';
import Rule from '@/views/company/Rule.vue';
import ServeHotLine from '@/views/serveline/serveHotLine.vue';
import ComputerInstallation from '@/views/computer/ComputerInstallation.vue';
import computerInstallDesc from '@/views/computer/computerInstallDesc.vue';
import CampusIntroduce from '@/views/campusIntroduce/CampusIntroduce.vue';
import Employee from '@/views/employee/Employee.vue'
import Dorms from '@/views/employee/Dorms.vue'
import RecepteVisitor from '@/views/receptevisitor/RecepteVisitor.vue'

Vue.use(VueRouter);

/**
 * Asynchronously load view (Webpack Lazy loading compatible)
 * @param  {string}   name     the filename (basename) of the view to load.
 */
function view(name) {
  name = !name.startsWith('/') ? '/' + name : name;
  return function(resolve) {
    require(['@/views' + name], resolve);
  };
}

const routes = [
  {
    path: '*',
    redirect: '/'
  },
  {
    path: '/',
    name: 'home',
    component: Home
  },
  {
    path: '/add',
    name: 'add',
    component: Add
  },
  {
    path: '/mine',
    name: 'mine',
    component: Mine
  },
  {
    path: '/recentList',
    name: 'recentList',
    component: RecentList
  },

  
  {
    path: '/checking',
    name: 'checking',
    component: Check
  },
  {
    path: '/attendance',
    name: 'attendance',
    component: Attendance
  },
  {
    path: '/extrawork',
    name: 'extrawork',
    component: Extrawork
  }, 
  {
    path: '/businessTrip',
    name: 'businessTrip',
    component: Evection
  },
  {
    path: '/businessTripGo',
    name: 'businessTripGo',
    component: BusinessTrip
  },
  {
    path: '/businessTripburse',
    name: 'businessTripburse',
    component: BusinessTripBurse
  },
  {
    path: '/company',
    name: 'company',
    component: Company
  },
  {
    path: '/companyRule',
    name: 'companyRule',
    component: Rule
  },
  {
    path:'/serveHotLine',
    name:'serveHotLine',
    component:ServeHotLine
  },
  {
    path:'/computerInstallation',
    name:'computerInstallation',
    component:ComputerInstallation
  },
  {
    path:'/computerInstallDesc',
    name:'computerInstallDesc',
    component:computerInstallDesc
  },
  {
    path:'/campusIntroduce',
    name:'campusIntroduce',
    component:CampusIntroduce
  },
  {
    path:'/employee',
    name:'employee',
    component:Employee
  },
  {
    path:'/dorms',
    name:'dorms',
    component:Dorms
  },
  {
    path:'/recepteVisitor',
    name:'recepteVisitor',
    component:RecepteVisitor
  },
];

const router = new VueRouter({
  // 不要用history模式，有兼容性问题
  mode: 'hash',
  // base: Cfg.BaseUrl,
  routes
});

// router.beforeEach(async (to, from, next) => {
//   // 全局路由钩子
// });

export default router;
